//index.js
//获取应用实例
const app = getApp()
Page({
  data: {
    url: app.getUrl.Urlcom,
    toView: 'inToView1',
    on_id:1,
    servicelon:1,
    //区间
    leftMin: 0,
    leftMax: 10,
    rightMin: 0,
    rightMax: 10,
    leftValue: 0,
    rightValue: 10,
    leftValue1: 0,
    rightValue1:'50万以上',
    //样式
  },
  //点击导航轮播
  scrollToViewFn: function (e) {
    var _id = e.target.dataset.id;
    this.setData({
      toView: 'inToView' + _id,
      on_id: _id,
    })



  },
  //设置hover
  servicelon:function(e){
    var _id = e.target.dataset.id;
    var zidua = e.target.dataset.ziduan;
    var text = wx.getStorageSync('key' + _id);//获取对应的ID直
    var key = "key" + _id;//先用一个变量，把(info[0].gMoney)用字符串拼接起来
    if (text == 1){
      this.setData({
        [key]: '',
      })
      wx.setStorageSync('key'+_id, 0);

      this.select_all(_id,zidua);
    }else{
      this.setData({
        [key]: 1,
      })
      wx.setStorageSync('key' + _id, 1);
      this.select_all(_id,zidua);
    }
  },

  //查询全部得key
  select_all: function (id,zidua){
   
    var text='';
    var key = "key" + id;//先用一个变量，把(info[0].gMoney)用字符串拼接起来
    var keys = wx.getStorageSync(key);//获取对应的ID直
    var ids = wx.getStorageSync('ids');
    // 异步处理查询
      wx.request({
        url: app.getUrl.Urlcom + '/Home/Selection/shaixuan_all.html', //真实的接口地址
        method: 'post',
        data: { 'data_name': keys, 'data_id': id, 'zidua': zidua},
        header: {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        success: function (res) {
          // wx.setStorageSync('ids','');
          wx.setStorageSync('ids', res.data.id);//写入


          console.info(ids.id);
        },
      })

  },

  //整合筛选查询
  select_alls:function(){



  },

  onLoad: function (options) {
    for (var i = 1; i < 47; i++) {
      var text = wx.getStorageSync('key'+i);//获取对应的ID直
      var key = "key" + i;//先用一个变量，把(info[0].gMoney)用字符串拼接起来
      this.setData({
        [key]: text,
      })
    }
    var ids = wx.getStorageSync('ids');
    console.info(ids);
  },  

  // 区间
  //价格slider滑动
  leftSchange: function (e) {
    var that = this
    that.setData({
      isQuery: false
    })
    var value = e.detail.value
    if (value == that.data.rightValue) {
      if (that.data.rightValue == 6) value--
      else value++
    }
    var pive = value * 5;
    wx.setStorageSync('piveleft', pive);//设置最低车价
    that.setData({
      leftValue: value,
      leftValue1: pive
    })
  },
  //右边
  rightSchange: function (e) {
    var that = this
    that.setData({
      isQuery: false
    })
    var value = e.detail.value
    if (value == that.data.leftValue) {
      if (that.data.leftValue == 6) value--
      else value++
    }
    var pive = value*5;
    wx.setStorageSync('piveright', pive);//设置最高车价
    if (pive == 50){
      var pives = '50万以上';
      }else{
      var pives = pive + '万';
      }
    that.setData({
      rightValue: value,
      rightValue1: pives,
    })

  },

  //重置
  chognzhi:function(){
    for (var i = 1; i < 47; i++) {
      var key = "key" + i;//先用一个变量，把(info[0].gMoney)用字符串拼接起来
      this.setData({
        [key]: 0,
      })
      wx.setStorageSync('key' + i, 0);
    }
    var pivesleft = '0';
    var pivesright = '50万以上';
    this.setData({
      rightValue: 10,
      rightValue1: pivesright,
    })
    this.setData({
      leftValue: 0,
      leftValue1: 0,
    })
  },
  //转跳
  selectio_all:function(){
    wx.navigateTo({
      url: '../selectio_all/selectio_all',
    })
  },
})